/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cassys.servicelocator;

import cassys.ejb.sessionbean.LecturerBeanRemote;
import cassys.ejb.sessionbean.AssessmentBeanRemote;
import cassys.ejb.sessionbean.EvaluationBeanRemote;
import cassys.ejb.sessionbean.ModuleBeanRemote;
import cassys.ejb.sessionbean.PeerAssessmentBeanRemote;
import cassys.ejb.sessionbean.ResultViewBeanRemote;
import cassys.ejb.sessionbean.StudentBeanRemote;
import cassys.ejb.sessionbean.StudentModuleTeamBeanRemote;
import cassys.ejb.sessionbean.TeamBeanRemote;
import cassys.ejb.sessionbean.UserBeanRemote;

/**
 *
 * @author ASUS
 */

import java.util.logging.Level;
import java.util.logging.Logger;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ServiceLocator {
    
    private static ServiceLocator instance=null;

    private  ServiceLocator() {
    }
    
    static{        
        instance=new ServiceLocator();
    }
    
    public static ServiceLocator getInstance()
    {return instance;}
    
    
     public UserBeanRemote lookupUserBean() {
        try {
            Context c = new InitialContext();
            return (UserBeanRemote) c.lookup("UserBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
    }
	
	public StudentBeanRemote lookupStudentBean(){
         try {
            Context c = new InitialContext();
            return (StudentBeanRemote) c.lookup("StudentBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }
     
     public ModuleBeanRemote lookupModuleBean(){
         try {
            Context c = new InitialContext();
            return (ModuleBeanRemote) c.lookup("ModuleBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }
     
      public LecturerBeanRemote lookupLecturerBean(){
         try {
            Context c = new InitialContext();
            return (LecturerBeanRemote) c.lookup("LecturerBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }
     
      public TeamBeanRemote lookupTeamBean(){
         try {
            Context c = new InitialContext();
            return (TeamBeanRemote) c.lookup("TeamBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }
	 
	 
	   public AssessmentBeanRemote lookupAssessmentBean(){
         try {
            InitialContext c = new InitialContext();
            return (AssessmentBeanRemote) c.lookup("java:comp/env/ejb/AssessmentBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }
        
       public EvaluationBeanRemote lookupEvaluationBean(){
         try {
            Context c = new InitialContext();
            return (EvaluationBeanRemote) c.lookup("java:comp/env/ejb/EvaluationBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }
	 
	 public StudentModuleTeamBeanRemote lookupStudentModuleTeamBean(){
         try {
            Context c = new InitialContext();
            return (StudentModuleTeamBeanRemote) c.lookup("StudentModuleTeamBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }
        
       public PeerAssessmentBeanRemote lookupPeerAssessementBean(){
         try {
            Context c = new InitialContext();
            return (PeerAssessmentBeanRemote) c.lookup("PeerAssessmentBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }  
       
     public ResultViewBeanRemote lookupResultViewBean(){
         try {
            Context c = new InitialContext();
            return (ResultViewBeanRemote) c.lookup("ResultViewBean");
        }
        catch(NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught" ,ne);
            throw new RuntimeException(ne);
        }
     }   
     
}
